package com.husawang.husa.lib.base.net;

import com.husawang.husa.lib.base.Global;
import com.husawang.husa.lib.base.MyApplication;
import com.husawang.husa.lib.base.utils.HusaUtils;
import com.husawang.husa.lib.base.utils.PreferenceHelper;

import okhttp3.FormBody;

/**
 * Created by s on 2017/8/9.
 */

public class HusaFormBody {
	private static HusaFormBody mHusaFormBody;

	private HusaFormBody() {
	}

	public static HusaFormBody getInstance() {
		if (null==mHusaFormBody){
			return new HusaFormBody();
		}
		return mHusaFormBody;
	}


	public FormBody.Builder getFormBodyBuilder(){
		FormBody.Builder builder=new FormBody.Builder();
		String token = PreferenceHelper.readString(MyApplication.getInstance(), Global.HUSA_CONFIG_FILE_NAME,Global.LOGIN_TOKEN,"");
		String uid = PreferenceHelper.readString(MyApplication.getInstance(), Global.HUSA_CONFIG_FILE_NAME,Global.USER_UID,"");
		boolean isLogin = PreferenceHelper.readBoolean(MyApplication.getInstance(), Global.HUSA_CONFIG_FILE_NAME,Global.IS_LOGIN);
		String phoneType= HusaUtils.getInstance().getPhoneInfo()[2];
		if(isLogin){
			builder.add("token", token);
			builder.add("uid", uid);
		}
		builder.add("av", "Android-"+HusaUtils.getInstance().getPhoneVersion());
		builder.add("mt", phoneType);

		return builder;
	}

}
